package vista;


import java.awt.*;
import java.util.Set;

import javax.swing.*;

import modelo.Player;
import modelo.Partida;
import modelo.UpdateListener;


import tablero.Square;


@SuppressWarnings("serial")
public class GUI extends JFrame implements Vista{
	
	private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField playerField;
    private javax.swing.JTextField ubicationField;
    private javax.swing.JLabel playerLabel;
    private javax.swing.JLabel ubicationLabel;
    private JPanel mapa;
    private Partida partida;
    private OyenteModelo oyenteModelo;
    private int screenHeight;
    private int screenWidth;
    private final int FRAME_HEIGHT=800; //ancho de la ventana principal
    private final int FRAME_WIDTH=1400; //alto de la ventana principal
//    private Display display;
//    private Shell shell;
    
    
	public GUI(Partida partida) {
		super("El Misterio De La Abadia");
		
//		display=new Display();
//		shell=new Shell(display);

				
		this.partida=partida;
		oyenteModelo = new OyenteModelo();
		Toolkit toolkit =  Toolkit.getDefaultToolkit ();
		Dimension dim = toolkit.getScreenSize();
		this.screenHeight=dim.height;
		this.screenWidth=dim.width;
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		initComponents();
	}
	
	private void initComponents(){
		setSize(this.FRAME_WIDTH,this.FRAME_HEIGHT);
		setVisible(true);
		this.setLocation(this.screenWidth/2-(this.FRAME_WIDTH/2), this.screenHeight/2-(this.FRAME_HEIGHT/2));
		LayoutManager mgr= new BorderLayout();
		this.setLayout(mgr);
		mapa=new JPanel();
		mapa.setBackground(Color.BLACK);
		this.add(mapa, BorderLayout.CENTER);
		
		
	}
	
	public OyenteModelo getOyenteModelo() {
		return oyenteModelo;
	}

	public void setOyenteModelo(OyenteModelo oyenteModelo) {
		this.oyenteModelo = oyenteModelo;
	}



	private class OyenteModelo implements UpdateListener {

		@Override
		public void ubicacionActualizada(Player j) {
			// TODO Auto-generated method stub
			ubicationField.setText(j.getUbication().getSquareName());
		}

		@Override
		public void newPlayer(Player j) {
			// TODO Auto-generated method stub
			
		}


		@Override
		public void playerTurn(Player j) {
			// TODO Auto-generated method stub
			playerField.setText(j.getNombreJugador());
			ubicationField.setText(j.getUbication().getSquareName());	
		}

		@Override
		public void partidaEmpezada() {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void movements(Player j, Set<Square> casillasValidas) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void twoPlayersHere(Player j, Square c) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void cardsExchangeMode(Player j) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void deskCardEventLibrary(Player j) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void deskCardEventScriptorium(Player j) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void deskCardEventCripta(Player j) {
			// TODO Auto-generated method stub
			
		}
	}



	@Override
	public void welcome() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void readPlayers() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void turnOf(Player j) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void start() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void end() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void endOfTheTurn() {
		// TODO Auto-generated method stub
		
	
	}


}



